/**
 * 
 */
package org.vsg.stock.basic.persistence.file;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Date;
import java.util.List;
import java.util.Vector;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.vsg.stock.basic.domain.StockTick;
import org.vsg.stock.basic.persistence.StockTickDao;

/**
 * @author vison
 *
 */
public class StockTickDaoImpl implements StockTickDao {
	
	private File tickDir;

	@Resource
	private ReadTickFileProcessor readTickFileProcessor;


	public File getTickDir() {
		return tickDir;
	}

	public void setTickDir(File tickDir) {
		this.tickDir = tickDir;
	}

	/* (non-Javadoc)
	 * @see org.vsg.stock.basic.persistence.StockTickDao#findOneDayAllTicks(java.lang.String, java.util.Date)
	 */
	@Override
	public List<StockTick> findOneDayAllTicks(String stockCode, Date date)
			throws DataAccessException {
		// TODO Auto-generated method stub
		List<StockTick> allStockTick  = null;
		try {
			allStockTick = readTickFileProcessor.readData(tickDir, stockCode, date);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			allStockTick = new Vector();
			e.printStackTrace();
		}


		return allStockTick;
	}

	@Override
	public boolean checkStockTickDataExist(String stockCode, Date date)
			throws DataAccessException {
		// TODO Auto-generated method stub
		boolean result = readTickFileProcessor.checkFileExist(tickDir, stockCode, date);
		
		return result;
	}

	
	
}
